Replace Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Replace all items in a collection equal to a particular value with another values, yielding another collection.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T> Replace<T>(
	IEnumerable<T> collection,
	T itemFind,
	T replaceWith
)
Visual Basic (Declaration)
Public Shared Function Replace(Of T) ( _
	collection As IEnumerable(Of T), _
	itemFind As T, _
	replaceWith As T _
) As IEnumerable(Of T)
Visual C++
public:
generic<typename T>
static IEnumerable<T>^ Replace (
	IEnumerable<T>^ collection, 
	T itemFind, 
	T replaceWith
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection to process.
itemFind
T
The value to find and replace within collection.
replaceWith
T
The new value to replace with.

Return Value

An new collection with the items from collection, in the same order, with the appropriate replacements made.

Type Parameters

T

Remarks

The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals.

See Also